package com.sntk.organauthomanager.infrastructure.db.repository;

import com.sntk.organauthomanager.infrastructure.db.entity.OrganizationEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface OrganizationDBRepository extends JpaRepository<OrganizationEntity, Long>, JpaSpecificationExecutor<OrganizationEntity> {
    OrganizationEntity findFirstByInstitutionNumberAndDelFalse(String institutionNumber);
    OrganizationEntity findFirstBySuperiorNumberOrderByInstitutionNumberDesc(String superiorNumber);
    OrganizationEntity findFirstByInstitutionNumberNotAndSuperiorNumberIsNullOrderByInstitutionNumberDesc(String institutionNumber);
    List<OrganizationEntity> findAllBySuperiorNumberAndDelFalseOrderByInstitutionNumberAsc(String superiorNumber);
    List<OrganizationEntity> findAllByDelFalseOrderByInstitutionNumberAsc();
    List<OrganizationEntity> findAllByInstitutionNumberNotInAndDelFalseAndDisabledFalse(List<String> organCodes);

    //名字
    List<OrganizationEntity> findAllByInstitutionNameLikeAndDisabledFalseAndDelFalse(String institutionName);

    List<OrganizationEntity> findAllByInstitutionNumberNotInAndInstitutionNameLikeAndDelFalseAndDisabledFalse(List<String> organCodes, String institutionName);
}
